package com.itheima.mapper;

import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface UserMapper {
    /**
     * 根据用户名和密码查询用户对象
     */
    @Select("select * from tb_user where username=#{username} and password=#{password}")
    User select(@Param("username") String username,@Param("password") String password);

    /**
     * 根据用户名查询用户对象
     * @param username
     * @return
     */
    @Select("select * from tb_user where username=#{username}")
    User selectByUsernames(String username);

    /**
     * 添加用户
     * @param user
     */
    @Insert("insert into tb_user value (null,#{username},#{password})")//这边括号里面的null指的是id，设置为null，id自动会增加，不用单独设置id
    void add(User user);
}
